//
//  LLLabelAddCell.m
//  LLLabel
//
//  Created by LQ on 2020/12/9.
//

#import "WKLabelAddCell.h"
#import "WKLabelModule.h"

@implementation WKLabelAddModel

- (Class)cell {
    return WKLabelAddCell.class;
}

@end

@interface WKLabelAddCell ()

@property(nonatomic,strong) UIImageView *iconImgView;
@property(nonatomic,strong) UILabel *titleLbl;

@end

@implementation WKLabelAddCell

- (void)setupUI {
    [super setupUI];
    [self.contentView addSubview:self.titleLbl];
    [self.contentView addSubview:self.iconImgView];
}

- (void)refresh:(WKLabelAddModel *)model {
    [super refresh:model];
    if(model.title && ![model.title isEqualToString:@""]) {
        self.titleLbl.text = model.title;
    }
    [self.titleLbl sizeToFit];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.iconImgView.lim_left = 15.0f;
    self.iconImgView.lim_centerY_parent = self.contentView;
    
    self.titleLbl.lim_left = self.iconImgView.lim_right + 10.0f;
    self.titleLbl.lim_centerY_parent = self.contentView;
}

- (UILabel *)titleLbl {
    if(!_titleLbl) {
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.text = LLang(@"新建标签");
        [_titleLbl sizeToFit];
        _titleLbl.font = [[WKApp shared].config appFontOfSize:15.0f];
        _titleLbl.textColor = [WKApp shared].config.themeColor;
    }
    return _titleLbl;
}

- (UIImageView *)iconImgView {
    if(!_iconImgView) {
        _iconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 18.0f, 18.0f)];
        _iconImgView.image = [self imageName:@"add"];
    }
    return _iconImgView;
}
- (UIImage*) imageName:(NSString*)name {
    return [[WKApp shared] loadImage:name moduleID:[WKLabelModule gmoduleId]];
}

@end
